#include <iostream>
#include <thread>

int main() {
    int x = 5;
    
    // 创建一个新线程，lambda表达式作为线程的执行体
    std::thread t([&x]() {
        std::cout << "Hello from thread! x = " << x << std::endl;
        x = 10;
    });
    
    // 主线程继续执行
    std::cout << "Hello from main thread! x = " << x << std::endl;
    
    // 等待新线程执行完毕
    t.join();
    
    // 输出修改后的x值
    std::cout << "After thread execution, x = " << x << std::endl;
    
    return 0;
}
